/*
 * @Author: Elephant 
 * @Date: 2017-06-08 10:25:01 
 * @Last Modified by: Elephant
 * @Last Modified time: 2017-06-08 22:30:40
 */
(function regLogin() {
    var regTel,
        regEmail,
        regTelLink,
        regEmailLink,
        errorTips;
    regTel = document.getElementById('regTel');
    regEmail = document.getElementById('regEmail');
    regTelLink = document.getElementById('regTelLink');
    regEmailLink = document.getElementById('regEmailLink');
    errorTips = document.getElementsByClassName('error-tips');

    //点击控制 display
    function display(btnEle, formEleNone, formEleBlock) {
        btnEle.onclick = function(e) {
            for (var i = 0; i < errorTips.length; i++) {
                var err = errorTips[i];
                err.style.display = "none";
            }
            formEleNone.reset();
            formEleNone.style.display = "none";
            formEleBlock.style.display = "block";
        }
    }
    display(regTelLink, regEmail, regTel);
    display(regEmailLink, regTel, regEmail);
})()

// 表单验证
var SMValidator = new SMValidator('form', {
    failCss: '', //验证失败时input添加的class名
    failStyle: {}, //验证失败时input内联样式
    passCss: '', //验证成功时input添加的class名
    passStyle: {}, //验证成功时input内联样式
    failHtml: ["<p class='error-tips'></p>"], //验证失败时input下方添加的内容,

    fields: {
        userName: {
            required: '昵称不能为空', //内容为空时提示的内容
            rule: [/^[a-zA-Z0-9]{4,10}$/, '昵称需在4-15位字母数字之间'], //验证失败时提示的内容
        },
        userTel: {
            required: '手机号不能为空', //内容为空时提示的内容
            rule: [/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/, '请输入正确的手机号'], //验证失败时提示的内容
        },
        userEmail: {
            required: '邮箱不能为空', //内容为空时提示的内容
            rule: [/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/, '请输入有效的邮箱地址'], //验证失败时提示的内容
        },
        userPassword: {
            required: '密码不能为空', //内容为空时提示的内容
            rule: [/[a-zA-Z0-9]{6,}/, '请输入大于6位的密码，字母数字组成'], //验证失败时提示的内容
        },
        telCode: {
            required: '验证码为4位数字', //内容为空时提示的内容
            rule: [/^\d{4}$/, '验证码有误'], //验证失败时提示的内容
        },
    }
});

// 粒子背景效果
particlesJS('particles-js', {
    "particles": {
        // 粒子密度
        "number": {
            "value": 20,
            "density": {
                "enable": true,
                "value_area": 1000
            }
        },
        "color": {
            "value": ["#fc615d", "#fdbe41", "#34c84a"]
        },
        // 粒子形状
        "shape": {
            "type": ["circle", "circle", "circle"],
            "stroke": {
                "width": 0,
                "color": "#b61924"
            },
            "polygon": {
                "nb_sides": 0
            },
            "image": {
                "src": "img/github.svg",
                "width": 100,
                "height": 100
            }
        },
        // 粒子透明度
        "opacity": {
            "value": 0.7,
            "random": true,
            "anim": {
                "enable": true,
                "speed": 1,
                "opacity_min": 0.1,
                "sync": false
            }
        },
        // 粒子大小
        "size": {
            "value": 15,
            "random": true,
            "anim": {
                "enable": true,
                "speed": 10,
                "size_min": 1,
                "sync": false
            }
        },
        // 粒子连接线
        "line_linked": {
            "enable": true,
            "distance": 200,
            "color": "#00aeff",
            "opacity": 0.5,
            "width": 1
        },
        // 粒子移动速度
        "move": {
            "enable": true,
            "speed": 6,
            "direction": "none",
            "random": true,
            "straight": false,
            "out_mode": "out",
            "bounce": true,
            "attract": {
                // 是否开启鼠标吸引
                "enable": false,
                "rotateX": 600,
                "rotateY": 1200
            }
        }
    },
    "interactivity": {
        "detect_on": "canvas",
        "events": {
            "onhover": {
                "enable": false,
                "mode": "repulse"
            },
            "onclick": {
                "enable": true,
                "mode": "push"
            },
            "resize": true
        },
        "modes": {
            "grab": {
                "distance": 800,
                "line_linked": {
                    "opacity": 1
                }
            },
            "bubble": {
                "distance": 800,
                "size": 80,
                "duration": 2,
                "opacity": 0.8,
                "speed": 3
            },
            "repulse": {
                "distance": 400,
                "duration": 0.4
            },
            "push": {
                "particles_nb": 4
            },
            "remove": {
                "particles_nb": 2
            }
        }
    },
    "retina_detect": true
});

// jquery